home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Sound Cards
/
Programming Sound Cards.iso
/
sound_26
/
siren.asm
< prev
next >
Wrap
Assembly Source File
|
1995-01-01
|
4KB
|
87 lines
code_seg segment
assume cs:code_seg
org 100h
jmp start
;-------------------------------------------
;B/C Software ;Author
;520 North Stateline Rd
;Sharon, Pa 16146
;----------------------------------
count1 dw 8 ;delay counts
count2 dw 3
count3 dw 20
count4 dw 10
message1 db 'press Esc to Quit',0dh,0ah,'$' ;Esc to end siren
message2 db 'press any other key to play$' ;or to go again
;----------------------------------
start proc near
mov ah,9 ;DOS function number to print string
mov dx,offset message1 ;the message
int 21h ;DOS interrupt
mov ah,9 ;DOS function number to print string
mov dx,offset message2 ;the message
int 21h ;DOS interrupt
begin: mov ah,0 ;BIOS function wait for key press
int 16h ;BIOS interrupt
cmp ah,1 ;Esc scan code
jz done ;do we stop ?
call siren ;no call phasor sound
jmp begin ;go see if we do it again
done: mov ax,4c00h ;no exit back to DOS
int 21h ;DOS interrupt
start endp
;-----------------------------------------
siren proc near
cli ;no interrupts
mov bp,15 ;we want to do hole thing 15 times
mov al,10110110xb ;set up channel 2
out 43h,al ;send it to port
agin: mov bx,500 ;start frequency high
backerx:mov ax,bx ;place it in (ax)
out 42h,al ;send LSB first
mov al,ah ;move MSB into al
out 42h,al ;send it next
in al,61h ;get value from port
or al,00000011xb ;ORing it will turn on speaker
out 61h,al ;send number
mov cx,count1 ;number of delay loops
looperx:loop looperx ;so we can hear sound
inc bx ;increment (bx) lowers frequency pitch
cmp bx,4000 ;have we reached 4000
jnz backerx ;if not do again
backery:mov ax,bx ;if not put (bx) in (ax)
out 42h,al ;send LSB to port
mov al,ah ;place MSB in al
out 42h,al ;send it now
in al,61h ;get value from port
or al,00000011xb ;lets OR it
out 61h,al ;time to turn on speaker
mov cx,count2 ;loop count
loopery:loop loopery ;delay so we can hear sound
dec bx ;decrementing (bx) rises frequency pitch
cmp bx,500 ;have we reach 500
jnz backery ;if not go back
mov si,count3 ;place longer delay in (si)
mov di,count4 ;place longer delay in (di)
push si ;push it on the stack
push di ;push it on the stack
mov si,count1 ;place first delay in (si)
mov di,count2 ;place second delay in (di)
mov count3,si ;save 1st in count3 for next exchange
mov count4,di ;save 2nd in count4 for next exchange
pop di ;pop longer delay off stack
pop si ;pop longer delay off stack
mov count2,di ;place it in the second
mov count1,si ;place it in the first
dec bp ;decrement repeat count
jnz agin ;if not = 0 do hole thing again
in al,61h ;we be done
and al,11111100xb ;this number will turn speaker off
out 61h,al ;send it
sti ;enable interrupts
ret
siren endp
;----------------------------------
code_seg ends